// pages/citywide/citywide.js
// require("../templates/templates.js")
var app=getApp();
var util=require("../../utils/util.js");
var baseImgUrl = util.baseImgUrl;
var certifyUrl = baseImgUrl + "certifidImg.png";//已认证图片路径
var uncertifyUrl = baseImgUrl + "uncertifyImg.png";//未认证图片路径
var hotUrl= "../images/hot.png";//人气图片路径
var positionUrl= "../images/position.png";//距离图片路径
var distance=5;//测试数据  距离

var followedUrl= "../images/followed.png"//已关注的图片路径
var unfollowedUrl="../images/unfollowed.png"//未关注的图片路径
var  scanUrl= baseImgUrl + "scan.png"//浏览量图片
Page({

  /**
   * 页面的初始数据
   */
  data: {
    toplist:["关注","发现","附近"],//顶部选择框
    activeIndex:1,//默认选择发现
    activeClass: 0,//发现标签默认选中的类别，推荐
    activeClass2: 0,//附近标签默认选中的类别，推荐
    certifyUrl: baseImgUrl + "certifidImg.png",//已认证图片路径
    uncertifyUrl: baseImgUrl + "uncertifyImg.png",//未认证图片路径
    showfujin: false,//是否显示附近选择面板
    showclasses: false,//附近标签，是否显示选择类别
    classesBar: "为您精选以下标签",
    navlist: [{
      id:"0" ,
      name: "推荐",
    },
    {
      id: "1",
      name: "美妆达人",
    },
    {
      id: "2",
      name: "鞋子",
    }, {
      id: "3",
      name: "饰品包包",
    }, {
      id: "4",
      name: "美容护肤",
      }, {
        id:"5",
        name: "健身达人",
      }, {
        id: "6",
        name: "旅游",
      },],
    goodslist: [{
      id: 0,
      goodsUrl: baseImgUrl + "goods1.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容品的介绍内容商品的介绍内容商品的介绍内容s",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 45,
      sale:true,
      yuanjia:60,
      scanNum: 1234,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 1,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容",
      biaoqian: ["今日秒杀"],
      price: 95,
      sale: false,
      yuanjia: 95,
      scanNum: 1200,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 2,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商",

      price: 125,
      sale: true,
      yuanjia: 155,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 3,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商品的介绍内容商品的介绍内容商品的介绍内容",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 125,
      sale: true,
      yuanjia: 125,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 4,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商",
      biaoqian: ["今日秒杀", "特卖"],
      price: 125,
      sale: true,
      yuanjia: 155,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 5,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商品的介绍内容商品的介绍内容商品的介绍内容",
      biaoqian: ["今日秒杀", "HOT热卖",],
      price: 125,
      sale: false,
      yuanjia: 155,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }],
    shoplist: [{
      shopid: 1,
      xuhao: 1,
      index:1,
      shoplogo: "../images/bang.png",
      shopname: "巴黎欧莱雅徐州总店",
      certify: true,
      certifyUrl: certifyUrl,//已认证图片路径
      uncertifyUrl: uncertifyUrl,//未认证图片路径
      hotUrl: hotUrl,
      hotNum: 1520,
     
      positionUrl: positionUrl,
      distance:3,
      followedUrl: followedUrl,
      unfollowedUrl: unfollowedUrl,
     
      latitude: "35.0125",
      longitude: "117.35632",
      followFlag: false,
      certifyUrl: certifyUrl,//已认证图片路径
      uncertifyUrl: uncertifyUrl,//未认证图片路径
      picrul: [{
        url: baseImgUrl + "goods1.png",
        price: "56"
      }, {
        url: baseImgUrl + "goods1.png",
        price: "50"
      }, {
        url: baseImgUrl + "goods2.png",
        price: "9.9"
      }
      ]
    }, {
      shopid: 2,
      xuhao: 2,
      index: 2,
      shoplogo: "../images/bang.png",
      shopname: "巴黎欧莱雅徐州2店",
        certify: false,
        certifyUrl: certifyUrl,//已认证图片路径
        uncertifyUrl: uncertifyUrl,//未认证图片路径
        hotUrl: hotUrl,
        positionUrl: positionUrl,
        distance: 3.2,
      hotNum: 1500,
        followedUrl: followedUrl,
        unfollowedUrl: unfollowedUrl,
      latitude: "35.0125",
      longitude: "117.35632",
        followFlag: true,
      picrul: [{
        url: baseImgUrl + "goods1.png",
        price: "56"
      }, {
        url: baseImgUrl + "goods1.png",
        price: "30"
      }, {
        url: baseImgUrl + "goods2.png",
        price: "9.9"
      }
      ]
    }, {
      shopid: 5,
      xuhao: 3,
        index: 3,
      shoplogo: "../images/bang.png",
      shopname: "巴黎欧莱雅徐州总店",
      certify: true,
      certifyUrl: certifyUrl,//已认证图片路径
      uncertifyUrl: uncertifyUrl,//未认证图片路径
        hotUrl: hotUrl,
        positionUrl: positionUrl,
        distance: 5,
      hotNum: 1520,
        followedUrl: followedUrl,
        unfollowedUrl: unfollowedUrl,
      latitude: "35.0125",
      longitude: "117.35632",
      followFlag: true,
      picrul: [{
        url: baseImgUrl + "goods2.png",
        price: "56"
      }, {
        url: baseImgUrl + "goods2.png",
        price: "50"
      }, {
        url: baseImgUrl + "goods2.png",
        price: "50"
      }
      ]
    }, {
      shopid: 2,
      xuhao: 4,
        index: 4,
      shoplogo: "../images/bang.png",
      shopname: "巴黎欧莱雅徐州2店",
        certify: true,
      certifyUrl: certifyUrl,//已认证图片路径
      uncertifyUrl: uncertifyUrl,//未认证图片路径
        hotUrl: hotUrl,
        positionUrl: positionUrl,
        distance: 5.5,
      hotNum: 500,
        followedUrl: followedUrl,
        unfollowedUrl: unfollowedUrl,
      latitude: "35.0125",
      longitude: "117.35632",
        followFlag: true,
      picrul: [{
        url: baseImgUrl + "goods1.png",
        price: "56"
      }, {
        url: baseImgUrl + "goods1.png",
        price: "30"
      }, {
        url: baseImgUrl + "goods1.png",
        price: "9.9"
      }
      ]
    }],
  
    fujinList: [{
      id: 0,
      name: "全城",
      num: 50
    }, {
      id: 1,
      name: "鼓楼区",
      num: 88
    }, {
      id: 2,
      name: "云龙区",
      num: 150
    }, {
      id: 3,
      name: "泉山区",
      num: 23
    }, {
      id: 4,
      name: "贾汪区",
      num: 23
    }],
    
  },
  /************点击全城***************** */
  showfujin:function(){
    var that=this;
    var flag=that.data.showfujin;
    console.log(flag)
    if(!flag){
      that.setData({
        showfujin:true
      })
      flag=true;
    }else{
      that.setData({
        showfujin: false
      })
      flag = false
    }
  },
  /**************点击右侧搜索图标*************** */
  tosearch:function(){
    wx.navigateTo({
      url: '/pages/search/search',
    })
  },
  /*************选择附近区域***************/
  choseDist:function(){
      var that=this;
      that.setData({
        showfujin: false
      })
    //请求数据

    util.loading();
  },
  /***********关闭附近区域弹出框************* */
  hideGrey:function(){
    var that = this;
    that.setData({
      showfujin: false,
      showclasses:false
    })
  },

  /***********附近标签，点击导航栏右侧按钮，显示弹出面板，选择分类************ */
  showClasses:function(){
    var that = this;
    that.setData({
      showclasses: true
    })
  },
  /***********关注**************/
  guanzhu:function(e){
   console.log("-----------guanzhu ------------")
    console.log(e);
    var that=this;
    var shopid=e.currentTarget.dataset.id;
    var xuhao = e.currentTarget.dataset.xuhao;
    that.data.shoplist[xuhao-1].followFlag=true;
    that.setData({
        shoplist:that.data.shoplist
    })
   
    //请求接口

  },

  /***************取消关注********************* */
  quxiaoguanzhu:function(e){
    var that=this;
    var shopid = e.currentTarget.dataset.id;
    var index=e.currentTarget.dataset.index;
    wx.showModal({
      title: '',
      content: '确定取消关注',
      confirmColor:"#ff1313",
      success:function(res){
        if(res.confirm){
          console.log("点击了确定，请求接口")
          that.data.shoplist[index - 1].followFlag = false;

          that.setData({
            shoplist: that.data.shoplist
          })
           //请求接口


        }else if(res.cancel){
          console.log("点击了取消")
        }
      },
     
    })


  },
  /***************发现标签点击导航效果***************** */
  choseNav:function(e){
      var that=this;
      var activeClass=e.currentTarget.dataset.index;
      var thisId=e.currentTarget.dataset.id;
      that.setData({
        activeClass:activeClass,
        toView: "item" + activeClass
      })
      console.log(e);
      //请求接口，获取数据
  },

  /***************点击顶部导航***************** */
  choseNav2: function (e) {
    var that = this;
    var activeClass = e.currentTarget.dataset.index;
    var thisId = e.currentTarget.dataset.id;
    that.setData({
      activeClass2: activeClass,
      toView: "item" + activeClass+"2"
    })
    console.log(e);

     //请求接口，获取数据
  },
  /***************点击发现 导航栏 右侧按钮************* */
  getmore:function(){
      var that=this;
      wx.navigateTo({
        url: '/pages/classes/classes',
      })
  },
  
  /*************点击弹出面板的标签*****************/
  choseClass:function(e){
      var that=this;
      var activeClass2=e.currentTarget.dataset.index;
      console.log(e);
      that.setData({
        activeClass2:activeClass2,
        showclasses:false,
        toView:"item"+activeClass2+"2",
      })
    
      console.log(e);

      util.loading();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
 
  /************选择nav*****************/
  choseTop:function(e){
      console.log(e);
      var activeIndex=e.currentTarget.dataset.index;
      var that=this;
      that.setData({
        activeIndex:activeIndex
      })
      util.loading();
  },

  /**********进入店铺************ */
  enterShop:function(e){
    console.log(e);
    var shopId=e.currentTarget.dataset.id;
    //跳转页面
    wx.navigateTo({
      url: '/pages/shopIndex/shopIndex?shopId='+shopId,
      
    })

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})